package org.pybaldaj.logic;

import javax.management.InvalidAttributeValueException;

/**
 * Class describing the game field.
 * @author akademi4eg
 *
 */
public class Field {

	public Field (int cells_num)
	{
		cells = new Cell[cells_num];
		for (@SuppressWarnings("unused") Cell c : cells)
		{
			c = new Cell();
		}
	}
	
	interface Point {
		int toIndex ();
		int getCoordinate (int index);
		Point[] getNeighbours ();
		boolean isNeighbour (Point p);
	}
	
	interface Dimensions {
		int getDimension(int index);
		int getDimensionsNum();
	}
	
	public Cell getCell (Point p)
	{
		return cells[p.toIndex()];
	}
	
	protected Cell getCell (int index)
	{
		return cells[index];
	}
	
	class Cell
	{
		public Cell ()
		{
			value = -1;
		}
		
		public void setValue (int a_val) throws InvalidAttributeValueException
		{
			if (a_val > letters.length())
				throw new InvalidAttributeValueException("Invalid letter index.");
			
			value = a_val;
		}
		
		public int getValue ()
		{
			return value;
		}
		
		private int value;
	}
	
	public static String getABC ()
	{
		return letters;
	}
	
	public static void setABC (String abc)
	{
		letters = abc;
	}
	
	private static String letters;
	protected Cell[] cells;
	protected Dimensions dimensions;
}
